﻿/*
 * TcpSecureConnection.h
 *
 */
#ifndef __GDK_TCPSECURECONNECTION_H__
#define __GDK_TCPSECURECONNECTION_H__

#include <gdk/core/Types.h>
#include <gdk/net/TcpConnection.h>
#include <gdk/net/SecureSession.h>



namespace gdk
{



class GDK_NET_EXPORT TcpSecureConnection : public TcpConnection
{
	DECLARE_CLASS_HANDLE(TcpSecureConnection)
	DECLARE_CLASS_INSTANCE(TcpSecureConnection)

	class SecureLayer
	{
	public:
		TcpSecureConnection	*_conn;

	public:
		__INLINE__ SecureLayer(void)
			: _conn(NULL)
		{}

		ssize_t receive(void *buf, ssize_t size);
		ssize_t send(const void *data, ssize_t size);
		String  getUrl(void) const;
	};

private:
	SecureLayer		_secureLayer;
	SecureSession	_secureSession;


protected:
	TcpSecureConnection(void);
	~TcpSecureConnection(void);

public:
	virtual void    onTick(uint32_t timeSinceLastTick);
	virtual ssize_t available(void) const;
	virtual ssize_t receive(void *buf, ssize_t size);
	virtual ssize_t send(const void *data, ssize_t size);
	virtual void    close(void);
};







}//namespace gdk





#endif /*__GDK_TCPSECURECONNECTION_H__*/
